<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------

namespace app\model\user;


use crmeb\traits\ModelTrait;
use think\Exception;
use think\facade\Db;
use think\Model;

class ConfigUserLog extends Model
{
    use ModelTrait;

    protected $updateTime = false;
    protected $createTime = false;

    protected $hidden = [
        //    'create_time','update_time','delete_time'
    ];



    public static function ResisUserConfigLog(int $uid, string $field)
    {
        $uid_find = self::where("uid", $uid)->find();
        if(empty($uid_find)){
            self::insert([
                "uid" => $uid,
                "{$field}" => 1,
                "create_time" => time(),
            ]);
        }else{
            self::where("uid", $uid)->inc($field, 1)->update();
        }
    }


}
